package com.disruptor.disruptor;

import com.disruptor.bean.DataBean;
import com.jfinal.plugin.activerecord.Db;
import com.lmax.disruptor.WorkHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by mengdexuan on 2017/9/18 10:36.
 *
 * DataBean 消费者
 */
public class DataBeanHandler  implements WorkHandler<DataBean> {

	private static Logger log = LoggerFactory.getLogger(DataBeanHandler.class);

	@Override
	public void onEvent(DataBean event) throws Exception {

		Thread.sleep(1000*5);

		String table = "test";
		/*if (event.getId()==5){
			table = "asdf";
		}*/
		Db.update("update "+table+" set status = 3 where id = "+event.getId());

		log.info("消费数据(C) --> "+event);

	}
}
